package visualizer.input.concrete;

import java.awt.event.KeyEvent;

import processing.core.PImage;
import processing.core.PVector;
import visualizer.data.DataSource;

public class ButtonComponent extends GraphicalComponent<Integer> {

	public ButtonComponent(PVector position, PImage[] background,
			DataSource<Integer> input) {
		super(position, background, input);
	}

	public void mousePressed(PVector p) {
		super.mousePressed(p);
		if (hasFocus()) {
			getInput().set(getInput().get() + 1);
		}
	}
	
	public void handleKeyPress(char key) {
		if ((key == KeyEvent.VK_SPACE) || (key == KeyEvent.VK_ENTER)) {
			getInput().set(getInput().get() + 1);
		}
	}
}
